package org.fujay.langchain4jserver.domain.model.vo;

import lombok.Getter;
import lombok.RequiredArgsConstructor;

import java.util.Arrays;

/**
 * 模型类型枚举
 */
@Getter
@RequiredArgsConstructor
public enum ModelType {
    CHAT(1, "聊天模型"),
    EMBEDDING(2, "嵌入模型"),
    IMAGE(3, "图像模型");

    private final int code;
    private final String description;

    public static ModelType fromCode(int code) {
        return Arrays.stream(ModelType.values())
                .filter(type -> type.code == code)
                .findFirst()
                .orElseThrow(() -> new IllegalArgumentException("未知的模型编码: " + code));
    }

    public static ModelType fromName(String name) {
        return Arrays.stream(ModelType.values())
                .filter(type -> type.name().equalsIgnoreCase(name))
                .findFirst()
                .orElseThrow(() -> new IllegalArgumentException("未知的模型名称: " + name));
    }
}
